<?php
require("../inc/common.inc.php");
$web_title=$webdb['vpp_jigoucode'];
if($type == 'ajax'){
	$str="";
	if(empty($pageindex)){
		$pageindex=2;
	}
	$pagesize=intval($pagesize);
	if ($pagesize==0){
		$pagesize=8;
	}
	$table=" mx_news";
	$order="order by createtime desc, id desc";
	$column=" * ";
	$biaoid="id";
	$list=$db->list1($pageindex,$pagesize,$table,$column,$str,$order,$biaoid);

	$status = 0;
	if($list){
		$status = 1;
		foreach($list as $k => $v){
			if($v['createtime']){
				$list[$k]['createtime'] = toDate($v['createtime']);
			}
			if($v['picurl']){
				$list[$k]['picurl'] = "<img src='".get_photourl($v['picurl'])."' />";
			}
			
			if($v['content']){
				$list[$k]['content'] = wordscut($v['content'],500);
			}
		}
	}
	print_r(json_encode(array('status'=>$status,'data'=>$list)));
	exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1" name="viewport">
<title><?php echo $webdb['vpp_jigoucode'];?></title>
<meta name="searchtitle" content="<?php echo $webdb['description'];?>">
<meta name="description" content="<?php echo $webdb['description'];?>">
<meta name="keywords" content="<?php echo $webdb['metakeywords'];?>">
<meta content="application/xhtml+xml;charset=UTF-8" http-equiv="Content-Type">
<meta content="no-cache,must-revalidate" http-equiv="Cache-Control">
<meta content="no-cache" http-equiv="pragma">
<meta content="0" http-equiv="expires">
<meta content="telephone=no, address=no" name="format-detection">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<meta name="apple-mobile-web-app-capable" content="yes" /> <!-- apple devices fullscreen -->
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
</head>
<body>
<div id="ly_yifeng"><?php echo $webdb['vpp_jigoucode'];?></div>
<?php 
require("../w_head.php");
?>
<!-- <div id="ly_top"><img src="/images/top.jpg" /></div> -->
<!--新闻咨询-->
<?php 
	$str="";
	if(empty($pageindex)){
		$pageindex=1;
	}
	$pagesize=intval($pagesize);
	if ($pagesize==0){
		$pagesize=8;
	}
	
	$table=" mx_news ";
	$order="order by createtime desc, id desc";
	$column=" * ";
	$biaoid="id";
	$list=$db->list1($pageindex,$pagesize,$table,$column,$str,$order,$biaoid);
?>
<div id="ly_news">
    <ul>
    <?php foreach($list as $k => $v){?>
        <li>
            <h1 class="bu"><?php echo $v['title']?></h1>
            <span class="yi"><?php echo toDate($v['createtime'])?></span>
            <div class="cn"><?php if($v['picurl']){?><img src="<?php get_photourl($v['picurl'])?>" /><?php }?>
            <?php echo wordscut($v['content'],500);?>
            </div>
            <a href="news_view.php?id=<?php echo $v['id']?>"><h4>阅读全文>></h4></a>
        </li>
    <?php }?>
    </ul>
    <div class="more"><a href="javascript:void(null);" onclick="getAjax();">查看更多>></a></div>
</div>
<!--新闻咨询end-->
<input type="hidden" value="1" id="pageIndex" />
<script>
//每次刷新都默认为有下文
$('#pageIndex').val(1);
$('<div><a href="javascript:void(null);" onclick="pageScroll();" id="gotop" style="background-image: url(\'/images/click_up.png\');background-repeat: no-repeat;bottom: 55px;height: 50px;position: fixed;right: 8px;text-indent: -9999px;visibility: hidden;width: 50px;z-index: 100;"></a></div>').appendTo('body');
function pageScroll(){
	document.getElementById('gotop').style.visibility='hidden';
    //把内容滚动指定的像素数（第一个参数是向右滚动的像素数，第二个参数是向下滚动的像素数）
    window.scrollBy(0,-1000);
    //延时递归调用，模拟滚动向上效果
    scrolldelay = setTimeout('pageScroll()',100);
    //获取scrollTop值，声明了DTD的标准网页取document.documentElement.scrollTop，否则取document.body.scrollTop；因为二者只有一个会生效，另一个就恒为0，所以取和值可以得到网页的真正的scrollTop值
    var sTop=document.documentElement.scrollTop+document.body.scrollTop;
    //判断当页面到达顶部，取消延时代码（否则页面滚动到顶部会无法再向下正常浏览页面）
    if(sTop==0) clearTimeout(scrolldelay);
}

window.onscroll=function(){
    var sTop=document.documentElement.scrollTop+document.body.scrollTop;
	if(sTop>500){
	    document.getElementById('gotop').style.visibility='visible';
	}else{
	    document.getElementById('gotop').style.visibility='hidden';
	}
}

//动态获取
function getAjax(){
	layout();
}
var tag = true;
/**
 * 获取信息后布局
 * @author Tony
 */
function layout(){
	var pageIndex = parseInt($('#pageIndex').val());
	if(pageIndex && tag){
		tag = false;
		var newPageIndex = pageIndex+1;
		var html = '';
		$.post('news.php',{'type':'ajax','pageindex':pageIndex+1},function(re){
			tag = true;
			if(re.status == 1){
				$('#pageIndex').val(newPageIndex);
				var list = re.data;
				for(var i=0;i<list.length;i++){
		        	html +='<li>';
					html += '<h1 class="bu">'+list[i].title+'</h1>';
				 	html += '<span class="yi">'+list[i].createtime+'</span>';
				 	html += '<div class="cn">'+list[i].picurl;
				    html += list[i].content+'</div>'
				    html += '<a href="news_view.php?id='+list[i].id+'"><h4>阅读全文>></h4></a>';
				    html += '</li>';
				}
				$("#ly_news ul>li:last").after(html);
			}else{
				$('#pageIndex').val('0');
			}
		},'json');
	}
}
</script>
<?php $fenxiang_hide=1;require("../w_foot.php")?>